<template>
  <div class="container">
    <h2 style="font-size: 40px;margin-bottom: 10px">交易记录</h2>
    <el-table
        :data="tableData"
        border
        :header-cell-style="{textAlign:'center'}"
        :cell-style="columnStyle"
        style="width: 100%;"
        :default-sort="{prop: 'transDate', order: 'descending'}">
      <el-table-column
          prop="transDate"
          label="交易日期"
          sortable
          width="200">
      </el-table-column>
      <el-table-column
          prop="come"
          label="姓名"
          width="150">
      </el-table-column>
      <el-table-column
          prop="comecardid"
          label="卡号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="go"
          label="姓名"
          width="150">
      </el-table-column>
      <el-table-column
          prop="gocardid"
          label="卡号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="money"
          label="交易金额"
          sortable
          width="180">
      </el-table-column>
      <el-table-column
          prop="remark"
          label="备注">
      </el-table-column>
    </el-table>


  </div>

</template>

<script>
export default {
  data() {
    return {
      user: JSON.parse(window.localStorage.getItem("user")),
      tableData: []
    }
  },
  mounted() {
    this.initData();
  },
  methods: {
    columnStyle({row, column, rowIndex, columnIndex}) {
      if (columnIndex == 2 || columnIndex == 4) {
        return 'background:	#FFF8DC;'
      }
    },
    initData() {
      // let id = this.user[0].customerID;
      this.getRequest(`/api/trans`).then(resp => {
        if (resp) {
          if (resp.code == 1) {
            this.tableData = resp.data;
            console.log(this.tableData)
          }
        }
      })
    },
    formatter(row, column) {
      return row.address;
    }
  }
}
</script>

<style scoped>
.container {
  text-align: center;
}
</style>